package com.wk.thread;

import java.util.concurrent.atomic.AtomicInteger;

public class Shunxudaying {

	static volatile int i = 1;
	public static void main(String[] args) {
		//AtomicInteger i = new AtomicInteger(1);
		
		Thread a = new Thread(()-> {
			while (true) {
				if(i%2 == 1) {
					System.out.print(1);
					//i.incrementAndGet();
					i++;
				}
				
			}
			
		});
		Thread b = new Thread(()-> {
			while (true) {
				if(i%2 == 0) {
					System.out.print(2);
//					i.incrementAndGet();
					i++;
				}
				
			}
		});
		a.start();
		b.start();
	}

}
